﻿@{
    ViewBag.Title = "Home Page";
}

<div class="jumbotron">
    <h1>ASP.NET</h1>
    <p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
    <p><a href="http://asp.net" class="btn btn-primary btn-large">Learn more &raquo;</a></p>
</div>

<div class="row">
    <div class="col-md-3">
        @using (Ajax.BeginForm("GetPublishedProjectsPartial", "Projects", new AjaxOptions { HttpMethod = "Get", UpdateTargetId = "publishedProjects", LoadingElementDuration = 1, LoadingElementId = "loadingPanel" }))
        {
            <button type="submit" class="btn btn-primary" name="btnGetPublishedProjects" >Get published projects</button>
        }
    </div>
    <div class="col-md-8">
        @using (Ajax.BeginForm("AddProjectPartial", "Projects", null, new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "publishedProjects", OnBegin="openModal", OnComplete="closeModal" }, new { @class="form-horizontal", role="form" }))
        {
            <div class="form-group">
                @Html.Label("name", "Project name", new { @class = "col-sm-2 control-label" })
                <div class="col-sm-6">
                    @Html.TextBox("name", null, new { @class = "form-control" })
                </div>
            </div>
            <div class="form-group">
                @Html.Label("description", "Project description", new { @class = "col-sm-2 control-label" })
                <div class="col-sm-6">
                    @Html.TextBox("description", null, new { @class = "form-control" })
                </div>
            </div>
            <div class="form-group">
                @Html.Label("startDate", "Project start date", new { @class = "col-sm-2 control-label" })
                <div class="col-sm-6">
                    @Html.TextBox("startDate", null, new { @class = "form-control" })
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-6">
                    <button type="submit" class="btn btn-primary" name="btnAddProject"><span class="glyphicon glyphicon-plus-sign"></span> Add project</button>
                </div>
            </div>
        }
    </div>

</div>
<div id="loadingPanel" style="display: none;" class="alert alert-info">
    <span class="glyphicon glyphicon-refresh"> Working on it...</span>
</div>
<div id="publishedProjects">
</div>

<!-- Modal -->
<div class="modal fade" id="loadingModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <span class="glyphicon glyphicon-refresh"> Working on it...</span>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="row">
    <div class="col-md-4">
        <h2>Getting started</h2>
        <p>
            ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
            enables a clean separation of concerns and gives you full control over markup
            for enjoyable, agile development.
        </p>
        <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301865">Learn more &raquo;</a></p>
    </div>
    <div class="col-md-4">
        <h2>Get more libraries</h2>
        <p>NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.</p>
        <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301866">Learn more &raquo;</a></p>
    </div>
    <div class="col-md-4">
        <h2>Web Hosting</h2>
        <p>You can easily find a web hosting company that offers the right mix of features and price for your applications.</p>
        <p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301867">Learn more &raquo;</a></p>
    </div>
</div>

@section scripts {
    <script>
        function openModal() {
            $("#loadingModal").modal();
        }

        function closeModal() {
            $("#loadingModal").modal('hide');
        }
    </script>
}